package controllers.recovery;

import hprose.HproseClinetService;

import java.util.HashMap;
import java.util.Map;

import org.apache.commons.lang.StringUtils;

import play.cache.Cache;
import play.mvc.Controller;

import com.alibaba.fastjson.JSONObject;

import component.UserBis;
import constants.APIConstants;
import controllers.common.filter.BaseFilter;

public class RecoveryRecordAction extends Controller{
	public static void index(){
		Map<String, Object> recParams = new HashMap<String, Object>();
		Map<String, Object> opParams= new HashMap<String, Object>();
		JSONObject useList = new JSONObject();
		JSONObject opList = new JSONObject();
		if (StringUtils.isNotBlank(params.get("date"))) {
			recParams.put("date", params.get("date"));
		}
		if (StringUtils.isNotBlank(params.get("operator_id"))) {
			recParams.put("operator_id", params.get("operator_id"));
		}
		if ("2".equals(UserBis.currType())) {
			recParams.put("customer_id", UserBis.currUser());
			recParams.put("currPage", params.get("currPage"));
			recParams.put("pageSize", params.get("pageSize"));
			recParams.put("operator_id", params.get("operator_id"));
			recParams.put("date", params.get("date"));
			opParams.put("customer_id", UserBis.currUser());
			opParams.put("page", "1");
			opParams.put("pageSize", "10000");
			Object[] arguments = new Object[]{recParams};
			Object[] arguments2 = new Object[]{opParams};
			String res = HproseClinetService.synCall(APIConstants.RRMSI_GETRECORDBYCOMSUMERID, arguments,APIConstants.CUSTOMER_HOST, APIConstants.CUSTOMER_PORT);
			String res1= HproseClinetService.synCall(APIConstants.OMSI_GETOPERATOR, arguments2,APIConstants.CUSTOMER_HOST, APIConstants.CUSTOMER_PORT);;
			useList = JSONObject.parseObject(res);
			opList = JSONObject.parseObject(res1);
		} else if ("3".equals(UserBis.currType())) {
			recParams.put("operator_id", UserBis.currUser());
			recParams.put("date", params.get("date"));
			Object[] arguments = new Object[]{recParams};
			String res = HproseClinetService.synCall(APIConstants.RRMSI_GETRECORDBYCOMSUMERID, arguments,APIConstants.SUPPLIER_HOST, APIConstants.SUPPLIER_PORT);
			useList = JSONObject.parseObject(res);
		}
		render(useList,opList);
	}
	public void addRecoveryRecord(){
		render();
	}
	
	public void addRecoveryRecordDo(){
		render();
	}
}
